<?php

class DisplayHelper extends AppHelper{
    
    var $helpers = array('Html');
    
    public function linkSport($data){
        echo $this->Html->link($data['name'], array('controller' => 'sports', 'action' => 'view', $data['id']));
    }
    
    public function trick($type, $multiple, $spin){
        $name = '';
        if ($spin == 0 && $type == 'spin'){
            $type = 'No Spin';
            $spin = '';
        }
        else if ($spin == 0){
            $spin = '';
        }
        
        if ($multiple == 'simple'){
            $multiple = '';
        }
        
        $name = $multiple.' '.$type.' '.$spin;
        
        return $name;
        
    }
    
    
    public function iconDeleteLink($url,$param = array(
                                            'alt' => 'Delete',
                                            'width' => '25px',
                                            'height' => '25px',
                                            'title' => 'Supprimer'
                                            )){
            $param['url'] = $url;
            echo $this->Html->image('icon_delete.png',$param);
    }
    
    public function iconEditLink($url,$param = array(
                                            'alt' => 'Delete',
                                            'width' => '25px',
                                            'height' => '25px',
                                            'title' => 'Editer'
                                            )){
            $param['url'] = $url;
            echo $this->Html->image('icon_edit.png',$param);
    }
    
    public function iconMoreLink($url,$param = array(
                                            'alt' => 'Delete',
                                            'width' => '25px',
                                            'height' => '25px',
                                            'title' => 'Voir plus'
                                            )){
            $param['url'] = $url;
            echo $this->Html->image('icon_more.png',$param);
    }
    
    
    /**
     *  Lien pour consulter une vidéo
     * @param type $data 
     */
    public function usersVideoLink($data){
        return $this->Html->link($this->usersVideo($data), array(
            'controller' => 'UsersVideos', 
            'action' => 'view', 
            $data['id']
        ));
    }
    public function usersVideo($data){
        return $data['title'];
    }
    
    /**
     *  Lien pour consulter un utilisateur
     * @param type $data 
     */
    public function userLink($data){
        return $this->Html->link($this->user($data), array(
            'controller' => 'UsersVideo', 
            'action' => 'view', 
            $data['id']
        ));
    }
    public function user($data){
        return $data['name'].' '.$data['surname'];
    }
    
    
    public function usersVideosType($value){
        switch ($value){
            case 'VideosTrick':
                $val = 'Figure';
            break;
            case 'VideosTutorial':
                $val = 'Tutoriel vidéo';
            break;
            case 'VideosEditing':
                $val = 'Montage vidéo';
            break;
            default:
                $val = 'Non publié';
        }
        return $val;
    }
    
    public function videosTutorialLink($data){
        return $this->Html->link($data['title'], array('UsersVideos/view/'.$data['users_videos_id']));
    }
    public function videosTrickLink($data){
        return $this->Html->link($data['title'], array('UsersVideos/view/'.$data['users_videos_id']));
    }
    public function videosEditingLink($data){
        return $this->Html->link($data['title'], array('UsersVideos/view/'.$data['users_videos_id']));
    }
    
    
    
    public function flvplayer($filename){
        $data = '
            <noembed>  
                <object style="width:320px;height:260px">  
                    <param name="movie" value="flvplayer.swf?file='.$filename.'" />  
                    <param name="quality" value="high" />  
                </object>   
            </noembed>  
            <embed  width="320" height="260"  src="flvplayer.swf?file='.$filename.'" quality="high" type="application/x-shockwave-flash" />  
        ';
        
        return $data;
    }
}
?>
